/**
 * Created by IntelliJ IDEA.
 * User: ryan
 * Date: Sep 10, 2010
 * Time: 10:07:09 AM
 * To change this template use File | Settings | File Templates.
 */
$(function() {

    var spaces = wikid.findSpaces();
    $.each(spaces, function(i, val) {
       var link = $('<div class="space ui-widget-content"><a href="/_'+val+'/"><h3 class="ui-widget-header">'+val+'</h3></a></div>') ;
       $('.spacesPanel').append(link);
        link.resizable().draggable();
  
    });

     $('#createSpace').button({
        icons: { primary: 'ui-icon-plusthick'}
      })
      .click(function() {
           $("#dialog-form").dialog('open');
         return false;
     });

    $("#dialog-form").dialog({
			autoOpen: false,
			height: 300,
			width: 350,
			modal: true,
			buttons: {
				'Create Space': function() {

				},
				Cancel: function() {
					$(this).dialog('close');
                    $('#createSpace').button('refresh');
				}
			},
			close: function() {
				allFields.val('').removeClass('ui-state-error');
                $('#createSpace').button('refresh');
			}
		});

});